//
//  BTEProductOneView.swift
//  BTE
//
//  Created by Mike Zhang on 2025/8/5.
//

import UIKit

class BTEProductOneView: UIView {

    let imagev = UIImageView.init(image: UIImage.init(named: BTELanguageManager.shared.localizedImageString(forKey: "hrt4554454")))
    
    let badoy = UIImageView.init(image: UIImage.init(named: "Groupfwefwefwe1171276686"))
    
    let a1 = UILabel()
    
    let a1imagev = UIImageView.init(image: UIImage.init(named: BTELanguageManager.shared.localizedImageString(forKey: "Groupfwefwfwe3331171277331")))
    
    let a1tackf = UIImageView.init(image: UIImage.init(named: "Group fewfwefw1171276617"))
    
    let a2 = UILabel()
    
    let a2imagev = UIImageView.init(image: UIImage.init(named: "Group fwewewe1171276761"))
    
    let a2tackf = UIImageView.init(image: UIImage.init(named: "Group fewfwefw1171276617"))
    
    let button = UIButton.init()
    
    var clickA:(()->())?
    
    var clickB:(()->())?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        addSubview(imagev)
        imagev.snp.makeConstraints { make in
            make.left.right.equalToSuperview()
            make.top.equalToSuperview()
            make.height.equalTo(UIScreen.main.bounds.width * imagev.frame.height / imagev.bounds.width)
        }
        
        addSubview(badoy)
        badoy.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(16)
            make.top.equalTo(imagev.snp.bottom).offset(20)
            make.height.equalTo((UIScreen.main.bounds.width-32) * badoy.frame.height / badoy.bounds.width)
        }
        
        badoy.addSubview(a1)
        badoy.addSubview(a1imagev)
        badoy.addSubview(a1tackf)
        badoy.addSubview(a2)
        badoy.addSubview(a2imagev)
        badoy.addSubview(a2tackf)
        
        a1imagev.clipsToBounds = true
        a2imagev.clipsToBounds = true
        a1imagev.contentMode = .scaleAspectFill
        a2imagev.contentMode = .scaleAspectFill
        
        a1.font = UIFont.systemFont(ofSize: 16, weight: .bold)
        a1.textColor = UIColor.colorWithHex("#333333")
        a1.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(30)
            make.top.equalToSuperview().offset(23)
        }
        
        a1imagev.snp.makeConstraints { make in
            make.left.equalTo(a1)
            make.top.equalTo(a1.snp.bottom).offset(10)
            make.height.equalTo((UIScreen.main.bounds.width-45-151) *  a1imagev.bounds.height / a1imagev.bounds.width )
            make.width.equalTo(UIScreen.main.bounds.width-45-151)
        }
        
        a1tackf.snp.makeConstraints { make in
            make.centerY.equalTo(a1imagev)
            make.left.equalTo(a1imagev.snp.right).offset(37)
            make.width.height.equalTo(48)
        }
        
        
        a2.font = UIFont.systemFont(ofSize: 16, weight: .bold)
        a2.textColor = UIColor.colorWithHex("#333333")
        a2.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(30)
            make.top.equalTo(a1imagev.snp.bottom).offset(18)
        }
        
        a2imagev.snp.makeConstraints { make in
            make.left.equalTo(a1)
            make.top.equalTo(a2.snp.bottom).offset(10)
            make.height.equalTo((UIScreen.main.bounds.width-45-151) *  a1imagev.bounds.height / a1imagev.bounds.width )
            make.width.equalTo(UIScreen.main.bounds.width-45-151)
        }
        
        a2tackf.snp.makeConstraints { make in
            make.centerY.equalTo(a2imagev)
            make.left.equalTo(a2imagev.snp.right).offset(37)
            make.width.height.equalTo(48)
        }
        
        
        button.setTitle(title: BTELanguageManager.shared.localizedString(forKey: "Next"))
        button.setBackgroundColor(UIColor.colorWithHex("#39B4E6")!)
        button.setFont(UIFont.systemFont(ofSize: 18, weight: .bold))
        button.setTitleColor(.white)
        button.roundCorners(.allCorners, radius: 25)
        button.layer.borderWidth = 2
        button.layer.borderColor = UIColor.colorWithHex("#6C2724")?.cgColor
        addSubview(button)
        button.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(38)
            make.bottom.equalToSuperview().offset(-34)
            make.height.equalTo(50)
        }
        
        let t1 = UITapGestureRecognizer.init(target: self, action: #selector(click1))
        a1imagev.isUserInteractionEnabled = true
        a1tackf.isUserInteractionEnabled = true
        let t2 = UITapGestureRecognizer.init(target: self, action: #selector(click1))
        a1tackf.addGestureRecognizer(t2)
        a1imagev.addGestureRecognizer(t1)
        
        let t2eeee = UITapGestureRecognizer.init(target: self, action: #selector(click2))
        let t2eeee2 = UITapGestureRecognizer.init(target: self, action: #selector(click2))
        a2imagev.isUserInteractionEnabled = true
        a2tackf.isUserInteractionEnabled = true
        a2imagev.addGestureRecognizer(t2eeee)
        a2tackf.addGestureRecognizer(t2eeee2)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
  
    @objc func click1(){
        clickA?()
    }

    
    @objc func click2(){
        clickB?()
    }
}


